﻿var ns, toast,imageBrowser;
var app = new Vue({
    el: '#app',
    data: {
        ID:0,
        questions:[],

        type:1,//1调查问卷，2-社区投票
        previewImage: [],
        imgarr:[],
    },
    methods: {
        get_data: function () {
            var that = this;
            var options = {};
            options.ID = that.ID;
            options.type = that.type;
            options.action = "getwechatsurveydetail";
            toast.loading({
                title: "加载中",
                duration: 2000
            }, function (ret) { });
            ns.post(options, function (succeed, data, err) {
                toast.hide();
                if (succeed) {  
                    that.questions = data.questions;

                    // api.sendEvent({
                    //     name: 'isreadtrue',
                    // });
                } else if (err) {
                    api.toast({
                        msg: err,
                        duration: 2000,
                        location: 'bottom'
                    });
                }
            });
        },
        //图片预览
        // img_browser: function (img) {
        //     var that = this;
        //     wx.previewImage({
        //         current: img,
        //         urls: that.previewImage
        //     });
        // },
        img_browser: function(imgurl) {
            var that = this;
            var imgurls = [];
            imgurls.push(imgurl);
            imageBrowser.openImages({
                imageUrls: imgurls,
                showList: false,
                activeIndex: 0
            });
        },
    }
});

apiready = function () {
    api.parseTapmode();
    imageBrowser = api.require('imageBrowser');
    ns = window.Foresight.Util;
    toast = new auiToast();
    app.ID = api.pageParam.id || 0;
    app.type = api.pageParam.detailtype;
    app.get_data();
};